var app=angular.module('myApp', []).
  config(['$routeProvider', function($routeProvider) {
  $routeProvider.
      when('/', {templateUrl: 'field_upload.html', controller: ListExpMstCtrl}).      
      when('/cancel/', {templateUrl: 'field_upload.html', controller: ListExpMstCtrl}). 
      otherwise({redirectTo: '/'});
}]);


function ListExpMstCtrl($scope, $http,$window,$location,$filter)
 {	
    $scope.currentPage = 0;
    $scope.pageSize = 25;
	$scope.Math = window.Math;
	$scope.ed = false;	
		
    $http.get('field_upload_data.php?id=1').success(function(data) {			
		if(data[0].inwarddate=='y')
			data[0].inwarddate=true;
		else
			data[0].inwarddate=false;
			
		if(data[0].proposalno=='y')
			data[0].proposalno=true;
		else
			data[0].proposalno=false;
			
		if(data[0].policyno=='y')
			data[0].policyno=true;
		else
			data[0].policyno=false;
			
		if(data[0].awbno=='y')
			data[0].awbno=true;
		else
			data[0].awbno=false;
			
		if(data[0].filebarcode=='y')
			data[0].filebarcode=true;
		else
			data[0].filebarcode=false;
			
		if(data[0].cartonbarcode=='y')
			data[0].cartonbarcode=true;
		else
			data[0].cartonbarcode=false;
			
		if(data[0].districtid=='y')
			data[0].districtid=true;
		else
			data[0].districtid=false;
			
		if(data[0].courierid=='y')
			data[0].courierid=true;
		else
			data[0].courierid=false;
			
		if(data[0].remarks=='y')
			data[0].remarks=true;
		else
			data[0].remarks=false;
		$scope.mismast = data;				
		$scope.disp = data;				
    });
	
	$scope.upd= function(dataset)
	{
		var file = 'field_upload_data.php?id=2&dataset='+JSON.stringify(dataset);
		$http.post(file).success(function(data) {
			alert("Changes saved successfully");
			$scope.cancel();
		});
	}
	
	//Function to Clear 
    $scope.cancel= function()
	{
		$scope.activePath = null;
		$scope.activePath = $location.path('field_upload.php');
	};      
 }
    
        //Custom Filter Function to sort the record.
    app.filter('startingFrom', function() 
    {
            return function(input, start) 
            {
                start = +start; //parse to int
                return input.slice(start);
            };
    });
	
        